import type {DaoTypes} from "./dao.types.ts";

export type Meta = {
    db: DaoTypes,
    entity: string,
    code?: string,
}


export type MetaView = {
    fields?: { [key: string]: MetaField },
    path?: string,
    code?: string,
    meta_name?: string,
    view_name?: string,

    form_width?: number,
    form_height?: number,
    table_width?: number,
    table_height?: number,

    enable?: boolean,
    show_header?: boolean,
    allow_batch?: boolean,
    allow_search?: boolean,
    allow_sort?: boolean,
    allow_pop?: boolean,
    allow_insert?: boolean,
    allow_edit?: boolean,
    allow_remove?: boolean,
    allow_download?: boolean,
    allow_upload?: boolean,
}
export type MetaField = {
    prop?: string,
    label?: string,
    name?: string,
    domain?: string,
    tool?: string,
    refer?: MetaRefer,
    format?: MetaFormat,
    unit?: string | null,
    not_null?: boolean,
    read_only?: boolean,
    sortable?: boolean,
    allow_search?: boolean,
    allow_download?: boolean,
    allow_upload?: boolean,
    allow_update?: boolean,
    column_width?: number,
    align?: 'left' | 'center' | 'right',
    fixed?: '' | 'left' | 'right',
    header_color?: string | null,
    cell_color?: string | null,
    edit_on_table?: boolean,
    hide_on_table?: boolean,
    span?: number,
    hide_on_form?: boolean,
    hide_on_form_edit?: boolean,
    hide_on_form_insert?: boolean,
    hide_on_form_branch?: boolean,
    hide_on_form_leaf?: boolean,
}
export type MetaRefer = {
    entity?: string,
    value?: string,
    label?: string,
    display?: string,
    multiple?: boolean,
    strict?: boolean,
    remote?: boolean,
    includes?: object,
    excludes?: object,
    root?: number
}
export type MetaFormat = {
    maxlength?: number,
    type?: 'date' | 'datetime',
    min?: number | null,
    max?: number | null,
    step?: number | null,
    precision?: number | null,
    step_strictly?: boolean,
    accept?: string,
    width?: number | string,
    height?: number | string,
    locket?: boolean,
}